﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FGrubert.CrmQueueMonitor.WinForms
{
    /// <summary>
    /// Stores the sizing properties for the main window
    /// </summary>
    public class WidthConfiguration
    {
        private int _colStatusWidth = 30;
        /// <summary>
        /// Width of the Status column
        /// </summary>
        public int ColStatusWidth
        {
            get { return _colStatusWidth; }
            set { _colStatusWidth = value; }
        }

        private int _colNameWidth = 150;
        /// <summary>
        /// Width of the Name column
        /// </summary>
        public int ColNameWidth
        {
            get { return _colNameWidth; }
            set { _colNameWidth = value; }
        }

        private int _colItemsWidth = 40;
        /// <summary>
        /// Width of the Items column
        /// </summary>
        public int ColItemsWidth
        {
            get { return _colItemsWidth; }
            set { _colItemsWidth = value; }
        }

        private int _colNotWorkedOnWidth = 40;
        /// <summary>
        /// Width of the Avail. column
        /// </summary>
        public int ColNotWorkedOnWidth
        {
            get { return _colNotWorkedOnWidth; }
            set { _colNotWorkedOnWidth = value; }
        }

        private int _colLatestWidth = 70;
        /// <summary>
        /// Width of the Latest column
        /// </summary>
        public int ColLatestWidth
        {
            get { return _colLatestWidth; }
            set { _colLatestWidth = value; }
        }

        private int _colLongestWidth = 60;
        /// <summary>
        /// Width of the Longest column
        /// </summary>
        public int ColLongestWidth
        {
            get { return _colLongestWidth; }
            set { _colLongestWidth = value; }
        }

        private float _fontSize = System.Drawing.SystemFonts.DefaultFont.Size;
        /// <summary>
        /// Current font size
        /// </summary>
        public float FontSize
        {
            get { return _fontSize; }
            set { _fontSize = value; }
        }

        private int _rowHeight = 22;
        /// <summary>
        /// The height of the rows
        /// </summary>
        public int RowHeight
        {
            get { return _rowHeight; }
            set { _rowHeight = value; }
        }


        private int _windowWidth = 432;
        /// <summary>
        /// Width of the window
        /// </summary>
        public int WindowWidth
        {
            get { return _windowWidth; }
            set { _windowWidth = value; }
        }

        /// <summary>
        /// Creates a new WidthConfiguration for a window with the given width
        /// </summary>
        /// <param name="newWindowWidth">The new width of the window</param>
        /// <param name="fullScale">Perform a full scale of all sizes based on the window width</param>
        public WidthConfiguration(int newWindowWidth, bool fullScale)
        {
            float factor = 1;
            if (fullScale)
            {
                factor = (float)newWindowWidth / (float)this._windowWidth;
            }

            this.ColStatusWidth = (int)(this._colStatusWidth * factor);
            this.ColItemsWidth = (int)(this._colItemsWidth * factor);
            this.ColNotWorkedOnWidth = (int)(this._colNotWorkedOnWidth * factor);
            this.ColLatestWidth = (int)(this._colLatestWidth * factor);
            this.ColLongestWidth = (int)(this._colLongestWidth * factor);

            this.ColNameWidth = newWindowWidth - (this.ColStatusWidth + this.ColItemsWidth + this.ColNotWorkedOnWidth + this.ColLatestWidth + this.ColLongestWidth) -
                SystemInformation.VerticalScrollBarWidth - (SystemInformation.FrameBorderSize.Width * 2 * SystemInformation.BorderMultiplierFactor) - 12;

            this.RowHeight = (int)(this._rowHeight * factor);

            this.FontSize = this._fontSize * factor;

            this.WindowWidth = newWindowWidth;           
        }

        /// <summary>
        /// Creates a new WidthConfiguration for a window with the default width
        /// </summary>
        public WidthConfiguration()
        {
        }


    }
}
